package view
{
	import com.greensock.easing.Cubic;
	import com.greensock.greensock.TweenLite;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.utils.setTimeout;
	
	public class GameData extends Sprite
	{
		private var panel:Daoju;
		private var _numArray:Array=[];
		public static const GAME_START:String = "start";
		public function GameData()
		{
			super();
			panel = new Daoju();
			this.addChild(panel);
			
			_numArray.push(panel.num1.text,panel.num2.text,panel.num3.text);
			panel.buttonStart.addEventListener(MouseEvent.CLICK,onClick);
					
			x = 620;
			y = 95;
			TweenLite.to(this, 0.5, {x:620-width, ease:Cubic.easeOut});
			
		}
		
		/**
		 *隐藏这个模块 ,并从显示列表删除。
		 * 
		 */		
		public function meHide():void
		{			
			TweenLite.to(this, 0.5, {x:620, ease:Cubic.easeOut});	
			setTimeout(removeMe,600);
			
		}
		
		private function removeMe():void
		{						
			if(parent){
				parent.removeChild(this);			
			}
		}
		/**
		 *点击发出事件，代表游戏开始； 
		 * @param event
		 * 
		 */		
		protected function onClick(event:MouseEvent):void
		{
			dispatchEvent(new Event(GameData.GAME_START));
		}
		
		/**
		 *返回一个数组，代表道具1,2,3的数量 
		 * @return 
		 * 
		 */		
		public function get numArray():Array
		{
			return _numArray;
		}
			
		/**
		 *写入数组必须有三个元素，用来显示三个道具的数量 ;
		 * <></n>
		 * @param value
		 * 
		 */		
		public function set numArray(value:Array):void
		{
			_numArray = value;
			
			if(value[0],value[1],value[2]){									
				panel.num1.text = value[0];
				panel.num2.text = value[1];
				panel.num3.text = value[2];
			}
			
		}

	}
}